<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="layout :: htmlhead" th:with="title='后台管理'">
</head>
<body>
	<div class="layui-layout layui-layout-admin">
		    <div class="layui-header">
        <a href="/" class="layui-hide-xs" style="font-weight: bold;">
        <div  class="layui-logo">通用数据列表 </div>
        </a>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a href="/login.html">登录</a></li>
            <li class="layui-nav-item"><a href="/registry.html">注册</a></li>
        </ul>
    </div>
	<div class="layui-body">
         <div class="layui-container">
             <div class="layui-row">
                 <div class="layui-col-xs9" style="margin-top: 50px;">
					<p class="alert alert-error" style="display:none">User has bean registed!</p>
					<h2>Registry with Username and Password</h2>
					<form name="form" th:action="@{/user/registry}" target="rfFrame" 
						lay-filter="registrycommit" action="/user/registry" method="POST">
					<div class="layui-input-inline">
		            	<input type="text" name="username" required lay-verify="required" placeholder="用户名" autocomplete="off"
		                   class="layui-input">
			        </div>
			        <div class="layui-input-inline">
			            <input type="password" name="password" required lay-verify="required" placeholder="密码" autocomplete="off"
			                   class="layui-input">
			        </div>
			        <div class="layui-input-inline login-btn">
			            <button lay-submit lay-filter="registry" class="layui-btn">注册</button>
			        </div>
			        <hr/>
			        <p><a href="register.html" class="fl">立即注册</a><br>
			        <a href="javascript:;" class="fr">忘记密码？</a></p>
					</form>
        			<iframe id="rfFrame" name="rfFrame" src="about:blank" style="display:none;"></iframe>
				</div>
			</div>
		</div>
	</div>
	</div>
</body>
<script type="text/javascript">

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type='text/javascript'>
    layui.use(['form','laydate'], function(){
        var $ = layui.jquery;
        var form = layui.form;
		  var laydate = layui.laydate;
        form.render();
		
		//自定义表单验证规则举例 
		form
			.verify({
				ccode : function(value) {
					if (value.length < 5) {
						return 'ccode至少得5个字符啊';
					}
				},
				email : [
						/^[a-z0-9._%-]+@([a-z0-9-]+\.)+[a-z]{2,4}$|^1[3|4|5|7|8]\d{9}$/,
						'邮箱格式不对' ]
		});
		  //监听提交
		form.on('submit(registrycommit)', 
			function(data){
				if (data == "error"){
					var error=$(".alert");
					error.css('display','block'); 
				}else {
			      layer.msg('注册成功'+data);
			      window.location="/";
				}
			}
		);
    });

</script>
</html>